package com.ihd.ihardware.view.lock.view;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.ihd.ihardware.R;
import com.ihd.ihardware.databinding.ActivityLockNobindingBinding;
import com.ihd.ihardware.view.lock.viewmodel.LockBindViewModel;

import cn.wowjoy.commonlibrary.base.BaseActivity;
import cn.wowjoy.commonlibrary.utils.BLEUtils;
import cn.wowjoy.commonlibrary.widget.titlebar.TitleBar;

public class LockNoBindingActivity extends BaseActivity<ActivityLockNobindingBinding, LockBindViewModel> {

    @Override
    protected void init(Bundle savedInstanceState) {
        mImmersionBar.statusBarDarkFont(false).init();

        binding.mtitlebar.setLeftBack(this);
        binding.mtitlebar.setLeftImageResource(R.drawable.lock_nb_back);
        binding.mtitlebar.addAction(new TitleBar.Action() {
            @Override
            public String getText() {
                return null;
            }

            @Override
            public int getDrawable() {
                return R.drawable.lock_nb_add;
            }

            @Override
            public void performAction(View view) {
                if (!BLEUtils.getInstance().isBluetoothOpened()) {
                    Intent i = new Intent(LockNoBindingActivity.this, LockBluetoothActivity.class);
                    startActivity(i);
                } else {
                    Intent i = new Intent(LockNoBindingActivity.this, LockBindingActivity.class);
                    startActivity(i);
                    finish();
                }
            }
        });

        binding.bindlock.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!BLEUtils.getInstance().isBluetoothOpened()) {
                    Intent i = new Intent(LockNoBindingActivity.this, LockBluetoothActivity.class);
                    startActivity(i);
                } else {
                    Intent i = new Intent(LockNoBindingActivity.this, LockBindingActivity.class);
                    startActivity(i);
                    finish();
                }
            }
        });

    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_lock_nobinding;
    }

    @Override
    protected Class getViewModelClass() {
        return LockBindViewModel.class;
    }
}
